| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 |
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
|
describe('TileLayer', function () {
var tileUrl = '';
describe("#getMaxZoom, #getMinZoom", function () {
var map;
beforeEach(function () {
map = L.map(document.createElement('div'));
});
describe("when a tilelayer is added to a map with no other layers", function () {
it("has the same zoomlevels as the tilelayer", function () {
var maxZoom = 10,
minZoom = 5;
map.setView([0, 0], 1);
L.tileLayer(tileUrl, {
maxZoom: maxZoom,
minZoom: minZoom
}).addTo(map);
expect(map.getMaxZoom()).to.be(maxZoom);
expect(map.getMinZoom()).to.be(minZoom);
});
});
describe("accessing a tilelayer's properties", function () {
it('provides a container', function () {
map.setView([0, 0], 1);
var layer = L.tileLayer(tileUrl).addTo(map);
expect(layer.getContainer()).to.be.ok();
});
});
describe("when a tilelayer is added to a map that already has a tilelayer", function () {
it("has its zoomlevels updated to fit the new layer", function () {
map.setView([0, 0], 1);
L.tileLayer(tileUrl, { minZoom:10, maxZoom: 15 }).addTo(map);
expect(map.getMinZoom()).to.be(10);
expect(map.getMaxZoom()).to.be(15);
L.tileLayer(tileUrl, { minZoom:5, maxZoom: 10 }).addTo(map);
expect(map.getMinZoom()).to.be(5); // changed
expect(map.getMaxZoom()).to.be(15); // unchanged
L.tileLayer(tileUrl,{ minZoom:10, maxZoom: 20 }).addTo(map);
expect(map.getMinZoom()).to.be(5); // unchanged
expect(map.getMaxZoom()).to.be(20); // changed
L.tileLayer(tileUrl, { minZoom:0, maxZoom: 25 }).addTo(map);
expect(map.getMinZoom()).to.be(0); // changed
expect(map.getMaxZoom()).to.be(25); // changed
});
});
describe("when a tilelayer is removed from a map", function () {
it("has its zoomlevels updated to only fit the layers it currently has", function () {
var tiles = [ L.tileLayer(tileUrl, { minZoom:10, maxZoom: 15 }).addTo(map),
L.tileLayer(tileUrl, { minZoom:5, maxZoom: 10 }).addTo(map),
L.tileLayer(tileUrl, { minZoom:10, maxZoom: 20 }).addTo(map),
L.tileLayer(tileUrl, { minZoom:0, maxZoom: 25 }).addTo(map)
];
map.whenReady(function() {
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(25);
map.removeLayer(tiles[0]);
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(25);
map.removeLayer(tiles[3]);
expect(map.getMinZoom()).to.be(5);
expect(map.getMaxZoom()).to.be(20);
map.removeLayer(tiles[2]);
expect(map.getMinZoom()).to.be(5);
expect(map.getMaxZoom()).to.be(10);
map.removeLayer(tiles[1]);
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(Infinity);
});
});
});
});
});
|